<?php
class App_ACL_Initialize
{

    public $acl;
    private $roles;
    private $allACL;

    public function __construct()
    {
        
    }

    public function iniACL()
    {
        $this->acl = new Zend_Acl();
        $this->roles = Core_Role::getAll();
        $this->allACL = Core_ACL::getAllACL();
 
    }

    public function setRoles()
    {
        foreach ($this->roles as $r)
        {
            if (!$this->acl->has($r['role']))
            {
                $this->acl->addRole(new Zend_Acl_Role($r['role']));
            }
        }
    }

    public function setResources()
    {
        foreach ($this->allACL as $a)
        {
            if (!$this->acl->has($a['controller']."_".$a['action']))
            {
                $this->acl->add(new Zend_Acl_Resource($a['controller']."_".$a['action']));
            }
        }
    }

    public function setPrivilages()
    {
        $this->acl->deny();
        foreach ($this->roles as $role)
        {
            foreach ($all->allACL as $a)
            {
                $this->acl->allow($role['role'],null,$a['controller'].'_'.$a['action']);
            }
        }
    }

    public function setAcl()
    {
        Zend_Registry::set('acl',$this->acl);
    }

}
?>